package Java攻略._2_java_util_function包._3_Predicate接口;

import java.util.Arrays;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class _9_查找满足任意谓词的字符串 {

    public static void main(String[] args) {

        _9_查找满足任意谓词的字符串 _9 = new _9_查找满足任意谓词的字符串();
        String namesSatisfyingCondition = _9.getNamesSatisfyingCondition(str -> str.startsWith("jianke"), "jianke xuliang"
                , "xiake zhanxingfei"
                , "jianke baiyunrui"
                , "xiake liushijie");

        System.out.println(namesSatisfyingCondition);
    }

    public String getNamesSatisfyingCondition(Predicate<String> condition, String... names){

        return Arrays.stream(names)
                .filter(condition)
                .collect(Collectors.joining(", "));
    }

}
